package pers.mine;

import java.util.Scanner;

/**
 * @author Mine
 * @since 2016年11月25日_上午10:48:13
 */
public class One {
	private static int SIZE = 3;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		int[][] arr = new int[SIZE][SIZE];
		int i, j;
		Scanner in = new Scanner(System.in);
		System.out.println("请输入" + SIZE * SIZE + "个整数:");
		for (i = 0; i < SIZE; i++) {
			for (j = 0; j < SIZE; j++) {
				arr[i][j] = in.nextInt();
			}
		}
		System.out.println("排序前数组:");
		for (i = 0; i < SIZE; i++) {
			for (j = 0; j < SIZE; j++) {
				System.out.print(arr[i][j] + "\t");
			}
			System.out.println();
		}

		// 排序
		sort(arr);
		System.out.println("排序后数组:");
		for (i = 0; i < SIZE; i++) {
			for (j = 0; j < SIZE; j++) {
				System.out.print(arr[i][j] + "\t");
			}
			System.out.println();
		}

	}

	public static void sort(int[][] iArray) {
		int iRow = 0, iCol = 0, iColy = 0, iCur = 0, iMin = 0, iMinAdd = 0, iTemp = 0;

		for (iRow = 0; iRow < SIZE; iRow++) {
			for (iCol = 0; iCol < SIZE - 1; iCol++) {
				iMin = iArray[iRow][iCol];

				for (iColy = iCol + 1; iColy < SIZE; iColy++) {
					if (iArray[iRow][iCur] < iMin) {
						iMin = iArray[iRow][iColy];
						iMinAdd = iCur;
					}
				}
				iTemp = iArray[iRow][iCol];
				iArray[iRow][iCol] = iMin;
				iArray[iRow][iMinAdd] = iTemp;
			}
		}
	}
}
